package com.qf.smartplatform.controller;/*
*王浩政 
*whz
2022/9/14
21:56
*小米商城
*/


import com.qf.smartplatform.dto.R;
import com.qf.smartplatform.pojo.SysCategory;
import com.qf.smartplatform.service.CategoryService;
import com.qf.smartplatform.valigroup.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/categories")
public class CategoryController {

    private CategoryService categoryService;

    @Autowired
    public void setCategoryService(CategoryService categoryService){
        this.categoryService=categoryService;
    }

    @PostMapping("/category")
    public R addCategory(@RequestBody @Validated(Insert.class)SysCategory category){
        categoryService.addCategory(category);
        return R.OK();
    }
}
